/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "CAMPAIGN")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Campaign.findAll", query = "SELECT c FROM Campaign c"),
    @NamedQuery(name = "Campaign.findByIdCampaign", query = "SELECT c FROM Campaign c WHERE c.idCampaign = :idCampaign")})
public class Campaign implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_CAMPAIGN")
    private BigDecimal idCampaign;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "campaign", fetch = FetchType.LAZY)
    private List<ItemCampaign> itemCampaignList;
    @JoinColumns({
        @JoinColumn(name = "ID_BRANCHENTERPRISE", referencedColumnName = "ID_BRANCHENTERPRISE"),
        @JoinColumn(name = "ID_ENTERPRISE", referencedColumnName = "ID_ENTERPRISE")})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private BranchEnterprise branchEnterprise;

    public Campaign() {
    }

    public Campaign(BigDecimal idCampaign) {
        this.idCampaign = idCampaign;
    }

    public BigDecimal getIdCampaign() {
        return idCampaign;
    }

    public void setIdCampaign(BigDecimal idCampaign) {
        this.idCampaign = idCampaign;
    }

    @XmlTransient
    public List<ItemCampaign> getItemCampaignList() {
        return itemCampaignList;
    }

    public void setItemCampaignList(List<ItemCampaign> itemCampaignList) {
        this.itemCampaignList = itemCampaignList;
    }

    public BranchEnterprise getBranchEnterprise() {
        return branchEnterprise;
    }

    public void setBranchEnterprise(BranchEnterprise branchEnterprise) {
        this.branchEnterprise = branchEnterprise;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCampaign != null ? idCampaign.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Campaign)) {
            return false;
        }
        Campaign other = (Campaign) object;
        if ((this.idCampaign == null && other.idCampaign != null) || (this.idCampaign != null && !this.idCampaign.equals(other.idCampaign))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Campaign[ idCampaign=" + idCampaign + " ]";
    }
    
}
